package com.ayu.scalalearn.chapter06

/**
  * @Author 徐林玉
  * @Description Test03Constructor
  * @Date 2022/7/28 14:26
  * @Version 1.0
  */
object Test03Constructor {


  def main(args: Array[String]): Unit = {

    val stu3 = new Student2("ayu", 10)

    val stu2 = new Student2("ayu")

    val stu1 = new Student2()


    stu1.Student()


  }


}


class Student2() {

  //定义属性
  var name: String = _
  var age: Int = _

  println("主构造器方法被调用...")


  def this(name: String) {

    this()
    println("___")
    this.name = name
    println("辅助构造器方法被调用...")
    println(" name :" + name + "_age:" + age)

  }


  def this(name: String, age: Int) {

    this(name)

    this.age = age

    println("辅助构造器2被调用....")

    println(" name :" + name + "_age:" + age)

  }


  def Student(): Unit = {


    println(this.name + "++++" + this.age)
  }

}
